package com.zytlifeservice.service.find;

import com.zytlifeservice.domain.find.ImageText;
import com.zytlifeservice.repository.find.ImageTextRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 图文信息业务类
 * Created by Administrator on 2017/6/2.
 */
@Service
public class ImageTextService {
     @Autowired
     private ImageTextRepository imageTextRepository;//图片信息持久
    //添加图文信息
    @Transactional
    public Integer addImageText(ImageText imageText){
        Integer result=0;
        try{
            imageTextRepository.save(imageText);
            result=1;
        }catch (Exception ex){
            result=0;
            ex.printStackTrace();
        }
        return result;
    }
    //更新图文信息
    @Transactional
    public Integer updateImageText(ImageText imageText){
        Integer result=0;
        try{
            imageTextRepository.save(imageText);
            result=1;
        }catch (Exception ex){
            result=0;
            ex.printStackTrace();
        }
        return  result;
    }

    //查询单个图文信息
    public ImageText findOddImageText(String tname){
        return imageTextRepository.getImageTexts(tname);
    }

    //删除图文信息
    @Transactional
    public Integer deleteImageText(Long id){
        Integer result=0;
        try{
            imageTextRepository.delete(id);
            result=1;
        }catch (Exception ex){
            result=0;
            ex.printStackTrace();
        }
        return  result;
    }
}
